import fetch from 'common/src/utils/fetch';

/**
 * 分页查询已开课排课的课程信息
 */
export function queryMatchingProf(data) {
    return fetch({
        url: '/api/arrangementservice/profMatching/page',
        method: 'post',
        data
    })
}

/**
 * 查询课程的教学班节次和匹配人数信息
 * @param classIds
 */
export function getMatched(classIds) {
  return fetch({
    url: '/api/arrangementservice/profMatching/matched',
    method: 'post',
    data: classIds
  })
}

/**
 * 更新专业匹配人数
 * @param data numberMap:教学班ID和占用人数的映射， majorCode grade faculty
 */
export function updateMatched(data) {
  return fetch({
    url: '/api/arrangementservice/profMatching/save',
    method: 'post',
    data
  })
}


/**
 * 获取专业配对全部课程冲突信息，返回格式为
 {
   grade,majorCode,conflictClassIds(冲突教学班ID集合);
 }
 * @param openId
 */
export function getConflict(openId,calendarId,majors) {
  return fetch({
    url: '/api/arrangementservice/profMatching/conflict',
    method: 'post',
    params: {openId,calendarId},
    data: majors
  })
}


/**
 * 导出课程各专业可选课清单
 */
export function exportData(courseName,data) {
  return fetch({
    url: '/api/arrangementservice/profMatching/export',
    method: 'post',
    params: {course:courseName},
    data
  })
}
/**
 * 清空课程的专业配对信息
 */
export function clearMatched(classIds,grade,majorCode) {
  return fetch({
    url: '/api/arrangementservice/profMatching/clear',
    method: 'post',
    params: {
      grade,majorCode
    },
    data: classIds
  })
}
/**
 * 清空课程的专业配对信息
 * @param openId
 */
export function clearOpened(openId,campus) {
  return fetch({
    url: '/api/arrangementservice/profMatching/open/clear',
    method: 'post',
    params: {openId,campus}
  })
}